/**
 * LZ
 * 2021/11/09
 * @param {*} row 当前行数据
 * @param {*} info 需要显示的字段信息
 * @param {*} source 来源
 * @cite main.js
 * @el <span class="SunCustomHtmlBox" v-html="$SunCustomHtml(row, item_field.list, 'course_show_field')" />
 */
export function $getHtmlContent(row, info, source) {
  let data = ''
  switch (source) {
    case 'course_show_field': // 课程管理
    case 'evaluation_course_show_field': // 评价课程
    case 'new_evaluation_course_show_field': // 准入课程
    case 'expert_evaluation_course_show_field': // 专家——评价课程
    case 'expert_new_evaluation_course_show_field': // 专家——准入课程
    case 'teacher_evaluation_course_show_field': // 教师——评价课程
    case 'teacher_new_evaluation_course_show_field': // 教师——准入课程
      info.forEach((item) => {
        let line = ''
        item.forEach((el) => {
          if (el.key.lastIndexOf('.') !== -1) {
            const keyArray = el.key.split('.')
            let kContent = null
            keyArray.forEach((k, k_index) => {
              if (kContent) kContent = kContent[k]
              // if (!kContent) kContent = row[k]
              if (!kContent) {
                if (k_index) {
                  kContent = ''
                } else {
                  kContent = row[k]
                }
              }
            })
            line += `<div style="padding-right: 10px;">${el.title}：<span style="color:${kContent ? '#606266' : '#C0C4CC'}">${kContent || '暂无'}</span></div>`
          } else {
            line += `<div style="padding-right: 10px;">${el.title}：<span style="color:${row[el.key] ? '#606266' : '#C0C4CC'}">${row[el.key] || '暂无'}</span></div>`
          }
        })
        data += `<span style="width: ${100 / info.length}%;display: inline-block;padding: 10px 0">${line}</span>`
      })
      break
  }
  return data
}
/* 评价课程信息 原备份
<div class="flex_center_align" style="padding: 10px 0">
  <div v-for="field in item_field.list" :key="field.key" :style="{'width': (100 / item_field.list.length) + '%'}">
    <div v-for="el in field" :key="el.key" style="padding: 0 5px;">
      <div v-if="el.key.split('.').length === 1" class="flex_center_align" style="width: 100%;">
        <span style="display: inline-block;">{{ el.title }}</span>
        <span v-if="row[el.key.split('.')[0]]" style="display: inline-block;">：{{ row[el.key.split('.')[0]] }}</span>
        <span v-else style="color: #C0C4CC">：{{ '暂无' }}</span>
      </div>
      <div v-if="el.key.split('.').length === 2" class="flex_center_align" style="width: 100%;">
        <span style="display: inline-block;">{{ el.title }}</span>
        <span v-if="row[el.key.split('.')[0]]" style="display: inline-block;">：{{ row[el.key.split('.')[0]][el.key.split('.')[1]] }}</span>
        <span v-else style="color: #C0C4CC">：{{ '暂无' }}</span>
      </div>
      <div v-if="el.key.split('.').length === 3" class="flex_center_align" style="width: 100%;">
        <span style="display: inline-block;">{{ el.title }}</span>
        <span v-if="row[el.key.split('.')[0]]" style="display: inline-block;">：{{ row[el.key.split('.')[0]][el.key.split('.')[1]][el.key.split('.')[2]] }}</span>
        <span v-else style="color: #C0C4CC">：{{ '暂无' }}</span>
      </div>
    </div>
  </div>
</div>
*/

/* Row行展示：<div style="width: 180px;position: relative;" v-html="$SunTeacherHtml(group_item)" /> */
/* Column列展示：<div style="width: 180px;position: relative;" v-html="$SunTeacherHtml(group_item, 'column')" />
*/
/**
 * @param {*} row 当前行数据
 * @param {*} style row行展示 column列展示
 */
export function $getTeacherHtml(row, style, isExtra = false) {
  let data = ''
  switch (style) {
    case 'row': // 行
      row.evaluation_course_teachers.forEach((item, item_index) => {
        data += `
          <div style="width: 100%;">
          <div style="padding: 20px 10px;display: flex; flex-direction: row; justify-content: space-around; align-items:center;width: 100%;
            border-top: ${item_index ? '1px dashed #EBEEF5' : ''}
          ">
              ${isExtra
    ? `
                <div style="width: 32%"><strong style="color:#999999">姓名：</strong><span style="color:${item.teacher.name ? '#606266' : '#C0C4CC'}">${item.teacher.name || '暂无'}</span></div>
                <div style="width: 25%"><strong style="color:#999999">工号：</strong><span style="color:${item.teacher.employee_no ? '#606266' : '#C0C4CC'}">${item.teacher.employee_no || '暂无'}</span></div>
                <div style="width: 25%"><strong style="color:#999999">电话：</strong><span style="color:${item.teacher.mobile ? '#606266' : '#C0C4CC'}">${item.teacher.mobile || '暂无'}</span></div>
                ${isExtra === 'reject_count' ? `<div style="width: 18%;text-align: center;"><strong style="color:#999999;">拒绝次数：</strong><span style="color:${item.reject_count ? '#FF0000' : '#409EFF'}">${item.reject_count}</span></div>` : `<div style="width: 18%;text-align: center;"><strong style="color:#999999;"></strong><span style="color:${item.temporary_storage === '已上传' ? '#409EFF' : '#C0C4CC'}">${item.temporary_storage || '未上传'}</span></div>`}
                
              `
    : `
              <div style="width: 33%"><strong style="color:#999999">姓名：</strong><span style="color:${item.teacher.name ? '#606266' : '#C0C4CC'}">${item.teacher.name || '暂无'}</span></div>
              <div style="width: 33%"><strong style="color:#999999">工号：</strong><span style="color:${item.teacher.employee_no ? '#606266' : '#C0C4CC'}">${item.teacher.employee_no || '暂无'}</span></div>
              <div style="width: 33%"><strong style="color:#999999">电话：</strong><span style="color:${item.teacher.mobile ? '#606266' : '#C0C4CC'}">${item.teacher.mobile || '暂无'}</span></div>
              `}
          </div>
          </div>
        `
      })
      break
    case 'column': // 列
      row.evaluation_course_teachers.forEach((item, item_index) => {
        data += `<div style="margin-top: ${item_index ? '10px' : '0px'};">
          <div><strong style="color:#999999">姓名：</strong><span style="color:${item.teacher.name ? '#606266' : '#C0C4CC'}">${item.teacher.name || '暂无'}</span></div>
          <div><strong style="color:#999999">工号：</strong><span style="color:${item.teacher.employee_no ? '#606266' : '#C0C4CC'}">${item.teacher.employee_no || '暂无'}</span></div>
          <div><strong style="color:#999999">电话：</strong><span style="color:${item.teacher.mobile ? '#606266' : '#C0C4CC'}">${item.teacher.mobile || '暂无'}</span></div>
        </div>`
      })
      break
  }
  return data
}
/** 原备份
<div style="width: 180px;position: relative;">
  <div v-for="(teacher_item, teacher_index) in group_item.evaluation_course_teachers" :key="teacher_index.id">
    <div style="padding: 10px;">
      <div><strong style="color:#999999">姓名：</strong>{{ teacher_item.teacher.name }}</div>
      <div><strong style="color:#999999">工号：</strong>{{ teacher_item.teacher ? teacher_item.teacher.employee_no : '' }}</div>
      <div><strong style="color:#999999">电话：</strong>{{ teacher_item.teacher.mobile }}</div>
    </div>
  </div>
  <div class="sun-table-border" />
</div>
*/
